<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>lesson 24</title>
  <style>
    /* 入场动画开始状态 */
    .v-enter-from {
      opacity: 0;
    }

    /* 入场动画过渡执行 */
    .v-enter-active,
    .v-leave-active {
      transition: opacity 3s ease-out;
    }

    /* 入场动画结束状态 */
    .v-enter-to {
      opacity: 1;
    }

    /* 出场动画开始 */
    /* .v-leave-from {
      opacity: 1;
    } */

    /* 出场动画结束 */
    .v-leave-to {
      opacity: 0;
    }
  </style>
  <script src="https://unpkg.com/vue@next"></script>
</head>

<body>
  <div id="root"></div>
</body>
<script>
  // 单元素，单组件的入场出场动画
  const app = Vue.createApp({
    data() {
      return {
        show: false
      }
    },
    methods: {
      handleClick() {
        this.show = !this.show
      }
    },
    template: `
      <transition>
        <div v-if="show">Hello World</div>     
      </transition>
      <button @click="handleClick">动画</button>
    `
  });

  const vm = app.mount('#root');
</script>

</html>